package logic;
import java.util.HashMap;
import java.util.Vector;


public class DeletedFiles {
	private HashMap<String, Vector<String> > ipFiles;

	public DeletedFiles()
	{
		this.setIpFiles(new HashMap<String,Vector<String> >()); 
	} 

	public synchronized HashMap<String, Vector<String> > getIpFiles() {
		return ipFiles;
	}

	public synchronized void setIpFiles(HashMap<String, Vector<String> > ipFiles) {
		this.ipFiles = ipFiles;
	}
	public synchronized Vector<String> getFilesID(String ip)
	{
		return getIpFiles().get(ip);
	}
	public synchronized void add(String fileID, Vector<String> ips)
	{
		for(int i =0; i< ips.size(); i++)
		{
			if(getIpFiles().containsKey(ips.elementAt(i)))
				getFilesID(ips.elementAt(i)).add(fileID);
			else 
			{
				Vector<String> tmp = new Vector<String>();
				tmp.add(fileID);
				getIpFiles().put(ips.elementAt(i),tmp);
			}
		}
	}
	public synchronized void deleteFileID(String ip,String fileID)
	{
		if(getIpFiles().get(ip) != null){
			getIpFiles().get(ip).remove(fileID);
			if(getIpFiles().get(ip).size()==0)
				getIpFiles().remove(ip);
		}
	}
}
